//package ClientServer;

import java.io.*;
import java.net.*;
import java.util.*;

public class Server {
	private int _port = 65000;
	private LinkedList<Client1> _listClients;
	public static PeerSet peer_set = new PeerSet();
	public static FileSet file_set = new FileSet();

	public static void main(String[] args)   {
		(new Server()).run();
	}

	public void run()   {
		_listClients = new LinkedList<Client1>();

		try {
			ServerSocket s = new ServerSocket(_port);   
			while(true) {
				Client1 cl = new Client1(s.accept(), peer_set, file_set);  // TODO il faut passer les structures de données (liste de fichiers et de peers)
				_listClients.add(cl);		
				cl.start();
			} 
			// s.close();
		}
		catch(Exception e) {
			System.out.println("Unable to start server: "+e.toString());
			return;
		}
	}
}

